package com.si.entite;

public class Pion extends Piece {
        String pathImage1= "./src/com/ChessApps/images/6.gif";
        String pathImage2= "./src/com/ChessApps/images/12.gif";
        
	boolean firstMove=true;
	public Pion(String couleur)
		{this.couleur = couleur;
		}

	@Override
	public boolean validerDep(Position posDepart, Position posFinal) {
		int diffColonne= posFinal.y-posDepart.y;
		int diffLigne= posFinal.x-posDepart.x;
		//verifier si cest son premier coups et donc accepter lavance de deux cases
		System.out.println("diffLigne: "+diffLigne+"\ndiffColonne: "+diffColonne);
		if (this.validerEchec(posFinal)){
                    // verifier si le deplacement est d'une case de colonne
                    if (firstMove)
                    {
                        if ( (((diffLigne==-1)||(diffLigne==1))
                                || ((diffLigne==-2)||(diffLigne==2))) && (diffColonne==0) )
                                {System.out.println("deplacement accepté"); firstMove = false;
				return true;}
                    
                    }
                    else{
                    if ( ((diffLigne==-1)||(diffLigne==1)) && (diffColonne==0) )
                                {System.out.println("deplacement accepté");
				return true;}
                    }
				
				return false;
	}return false;
        }

	
	public boolean manger(Position posDepart, Position posFinal) {
		int diffColonne= posFinal.x-posDepart.x;
		int diffLigne= posFinal.y-posDepart.y;
		
		if ((diffLigne==1)&&((diffColonne==1)||(diffColonne==-1)) )
		   {
			return true;
		   }
		return false;
	}

    @Override
    public String getPathImage(int i) {
       if (i== 1)
        {
            return pathImage1;
        }
        else {return pathImage2;}
    }

	
        

public String toString(){return "Pion";}
	
	
	
}
